package com.symone.webcms.service.impl;

import com.symone.webcms.model.DataGroup;
import com.symone.webcms.mapper.DataGroupMapper;
import com.symone.webcms.service.DataGroupService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 *　　
 *   @description : ContentGroup 服务实现类
 *   ---------------------------------
 * 	 @author Archer Chu
 *   @since 2019-03-25
 */
@Service
public class DataGroupServiceImpl extends ServiceImpl<DataGroupMapper, DataGroup> implements DataGroupService {

    @Override
    public DataGroup insertData(DataGroup dataGroup) {
        baseMapper.insert(dataGroup);
        return dataGroup;
    }

    @Override
    public Page<DataGroup> findPage(Page<DataGroup> page, Wrapper<DataGroup> contentGroup) {
        List<DataGroup> result = baseMapper.selectPage(page,contentGroup);
        page.setRecords(result);
        return page;
    }

    @Override
    public List<DataGroup> findAll() {
        Wrapper<DataGroup> ew = new EntityWrapper<DataGroup>();
        ew.where("deleted=0");
        return baseMapper.selectList(ew);
    }

    @Override
    public int delete(long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public boolean deleteFlagById(long id) {
        return baseMapper.deleteFlagById(id);
    }

    @Override
    public int clear() {
        return baseMapper.delete(new EntityWrapper<DataGroup>().eq("deleted" ,1));
    }
	
}
